package com.itheima.shengxiao;

public class Chuzi implements Runnable {
    @Override
    public void run() {
        while (true){
            synchronized (Desk.obj) {
                String name = Thread.currentThread().getName();
                //看看有没有饭
                if(Desk.fan){
                    //有  等着
                    try {
                        Desk.obj.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }else {
                    System.out.println(name+"做了一碗面");
                    Desk.fan=true;
                    //没有   做饭  做完 邀人
                    Desk.obj.notifyAll();
                }
                if(Desk.count==0){
                    break;
                }
            }
        }

    }
}
